package SM::Server::Packet::In::Avatar::Location;

use strict;
use warnings;

use Data::Dumper::Simple;

use SM::Constants;

use base 'SM::Server::Packet::In::Avatar';

sub new {
    my ( $class, $arg_ref ) = @_;

    my $self = $class->SUPER::new($arg_ref);

    $self->{sub_type} = AVATAR_LOCATION;


    my ( $data_type, $sub_type, $x, $y ) = unpack "CCZ*Z*", $arg_ref->{raw_data};

    $self->{x} = $x;
    $self->{y} = $y;
    $self->{username} = $arg_ref->{username};

    return $self;
}

sub dispatch {
    my ($self) = @_;
    SM::Server::GameLogic::update_client_location->({
        x      => $self->{x},
        y      => $self->{y},
        username => $self->{username},
    });
}

sub get_x {
    my ($self) = @_;

    return $self->{x};
}

sub get_y {
    my ($self) = @_;

    return $self->{y};
}

sub get_xy {
    my ($self) = @_;

    return ( $self->get_x(), $self->get_y() );
}

1;
